package ArrayTest;

import java.util.Arrays;

public class InsertionSort {
    public static void main(String[] args) {
        int []arr={5,7,3,1,6,9,4,2,8,0};
        System.out.println(Arrays.toString(arr));
        System.out.println();
        for (int i = 1; i <arr.length ; i++) {
            int j=i;
            while (j>0){
                if(arr[j]<arr[j-1]){
                    int t;
                    t=arr[j];
                    arr[j]=arr[j-1];
                    arr[j-1]=t;
                    j--;
                }else {
                    break;
                }
            }
            System.out.println(Arrays.toString(arr));
            System.out.println();
        }
    }
}
